This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 18, 2011, 9:09 PM
35 Posts
topic has been resolvedResolved

Get fields from names.nsf on Xpage

  • Category: Server Side JavaScript
  • Platform: Linux
  • Release: 8.5.2
  • Role: End user,Developer,Administrator
  • Tags:
  • Replies: 8
 Hello Forum,
 
I'm created a Xpage with some fields, I would like to populate these fields with the values present in the user's Person Document (names.nsf) 
 
I have a Computed Field with the username, in the other fields I would like the Department, Phone number... the values from the user's Person Document. 
 
I tried the next code, without results, strange enough if a replace $VIMPeople with $People, this gives me some result.
 db = new Array(@DbName()[0], 'names.nsf');
@DbColumn(db, "($VIMPeople)", 1)
 
Can someone help me with this. 
 
Thanks in advance, 
May 19, 2011, 2:27 PM
33 Posts
Re: Get fields from names.nsf on Xpage
If you want to work only with values present in a view you may try this:
 
var vw:NotesView = db .getView('ViewName');
var ve:NotesViewEntry = vw.getEntryByKey('XXXX', true) ;
 
where XXXX may be user name. 
 If you want to work with whole document you just have to slightly modify previous code:
 
 var vw:NotesView = db .getView('ViewName');
var userDoc:NotesDocument = vw.getDocumentByKey('XXXX', true) ;
 
For documentation of NotesViewEntry and NotesDocument classes refer to Designer help (Help->Help contents->Lotus Domino Designer XPages Reference)
May 19, 2011, 8:19 PM
35 Posts
Re: Get fields from names.nsf on Xpage
 Thx for your quick reply.
 
I tried but was enable to make it work... 
 
I added the next code to a computed field on my xpage in the Properties Tab - Value / Bind data using javascript section:
 
var db:NotesDatabase = session.getDatabase('', 'names.nsf');
var vw:NotesView = db.getView('$VIMPeople');
var userDoc:NotesDocument = vw.getDocumentByKey('Administrator/ChrisOrg', true);
var userFunc:String = userDoc.getItemValue('Title(0)');
 
It doesn't seem to work and gives me as result userFunc insteat of the Title of the Person Document. 
 
Can you tell me what I'm doing wrong. 
 
Thank you very much. 
 
Chris 
May 20, 2011, 5:09 AM
33 Posts
Re: Get fields from names.nsf on Xpage
Try ti change tha last line to this:
var userFunc:String = userDoc.getItemValueString('Title');
 
method getItemValueValue returns instance of java.util.Vector so you would have to write this: 
var userFunc:String = userDoc.getItemValue('Title').get(0);
 
May 20, 2011, 10:07 AM
35 Posts
Re: Get fields from names.nsf on Xpage
Thx for your reply.
 
I added the line that you gave me to the javascript code of a computed field on my xpage in the Properties Tab - Value / Bind data using javascript section:
 
var db:NotesDatabase = session.getDatabase('', 'names.nsf');
var vw:NotesView = db.getView('$VIMPeople');
var userDoc:NotesDocument = vw.getDocumentByKey('Administrator/ChrisOrg', true);
var userFunc:String = userDoc.getItemValueString('Title');
 
 It still returns me 'userFunc' insteat of the Title field from names.nsf!
 
Any idea? 
 
Thx in advance, 
 
Chris 
May 20, 2011, 11:08 AM
33 Posts
Re: Get fields from names.nsf on Xpage
Hi, try to add one more line:
return userFunc; 

May 20, 2011, 12:07 PM
35 Posts
Re: Get fields from names.nsf on Xpage
Thx again for your help.
 
It returns me nothing... I have totally no idea why!
 
var db:NotesDatabase = session.getDatabase('', 'names.nsf');
var vw:NotesView = db.getView('$VIMPeople');
var userDoc:NotesDocument = vw.getDocumentByKey('Administrator/ChrisOrg', true);
var userFunc:String = userDoc.getItemValueString('Title');
return userFunc;
 
I tried changing 'names.nsf' to something else, this generates an error in db.getView => This indicates me that the NotesDatabase is OK
Then I changed the '$VIMPeople', this generates an error on getDocumentByKey=> This indicates me that the getView is OK
Then I changed the 'Administrator/ChrisOrg', this generates an error on getItemValueString => This indicates me that the getDocumentByKey is OK
Changing 'Title' did nothing, no errors!
 
But now I'm sure that the begin of my code is OK...
 
Thx 
May 20, 2011, 12:47 PM
33 Posts
Re: Get fields from names.nsf on Xpage
The method getItemValueString return an empty string if the item does not exist on the document. 
May 20, 2011, 1:09 PM
35 Posts
Re: Get fields from names.nsf on Xpage
You'are right, my fault !!!
 
It's JobTitle that I filed in, Title is empty => reason why it returned me an empty string. 
 
Thank you very much for your time and assistance. 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal